<template style="position: fixed; width: 100%; overflow-x: hidden;">
	<view class="content">
		<ourloading :active="loadingFirst" text=" "  />
	</view>
</template>

<script>
	import ourloading from '@/components/our-loading/our-loading.vue'
	var util = require('@/js/util.js')
	export default {
		components:{
			ourloading,
		},
		data() {
			return {
				loadingFirst:true,
				parent_id:''
			}
		},
		created() {
			uni.hideTabBar()
		},
		onHide() {
		},
		onLoad(e) {
			console.log(e)
			this.getConfig()
			var parent_id = decodeURIComponent(e.scene);
			if(e.prizedraw_id){
				uni.setStorageSync("prizedraw_id",e.prizedraw_id)
			}
			if (e.parent_id) {
				// 如果打开的是分享页面，存储邀请人的id，用于核实邀请
				this.parent_id = e.parent_id
				uni.setStorageSync('parent_id', e.parent_id);
			}
			if(parent_id != "undefined" && parent_id != undefined){
				uni.setStorageSync('parent_id', parent_id);
			}
			
		},
		onShow() {
			
		},
		onShareAppMessage() { // 分享 buttom share
			return {
				title: '合成王者',
				path: '/pages/index/index?parent_id='+uni.getStorageSync('member_id')
			}
		},
		methods: {
			getConfig(){
				let _self = this
				uni.request({
					url: util.getUrl("config/index"),
					header: {
						'content-type': 'application/x-www-form-urlencoded',
					},
					data:{
					},
					method: 'POST',
					success: res => {
						var configPublic = res.data.data 
						configPublic['logo'] = res.data.data.app_logo;
						configPublic['appname'] = res.data.data.app_name;
						configPublic['diyColor'] = res.data.data.diy_color;
						uni.setStorageSync("diyColor",res.data.data.diy_color)
						uni.setStorageSync("menu",res.data.data.menu)
						_self.$store.commit("app_logo",res.data.data.app_logo)
						uni.getImageInfo({
							src: res.data.data.super_card_image,
							success: function (image) {
								uni.setStorageSync("super_card_image",image.path)
							},	
							fail(e) {
								
							},
							complete: (e) => {
							}
						});
						_self.appConfig = configPublic
						uni.setStorageSync('appconfig',_self.appConfig)
						let downloadnumber = 0
						for(let key in res.data.data.diy){
							uni.getImageInfo({
								src: res.data.data.diy[key],
								success: function (image) {
									res.data.data.diy[key] = image.path
									downloadnumber++
									if(downloadnumber == 4){
										_self.loadingFirst = false
										uni.setStorageSync("diyImg",res.data.data.diy)
										if(_self.parent_id){
											uni.navigateTo({
												url:'../login/login'
											})
										}else{
											// lutteryAssistant/luttery
											// other
											uni.reLaunch({
												url:'/synthesis/other/index'
											})
										}
									}
								},	
								fail(e) {
									downloadnumber++
								},
								complete: (e) => {
								}
							});
						}
						uni.getImageInfo({
							src: res.data.data.app_logo,
							success: function (image) {
								
							}
						});
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	
</style>
